package demo.equals;

import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * 2022/5/13 15:15
 *
 * @author by yd
 */
@Data
@Accessors(chain = true)
public class Son extends Father {
	private String name;
	private int age;

	@Override
	public Son setId(String id) {
		super.setId(id);
		return this;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Son son = (Son) o;

		return new EqualsBuilder().appendSuper(super.equals(o)).append(name, son.name).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(name).toHashCode();
	}


}
